package com.sky.Demo;

public class MovieOperator {
    //电影方法类
    Movie[] movies;
    public MovieOperator(Movie[] movies){
        this.movies = movies;
    }
    //1.实现展示所有电影的功能
    public void printAllMovies(){
        Movie m = new Movie();
        for (int i = 0; i < this.movies.length; i++) {
            m = movies[i];
            System.out.println("编号:" + m.getId());
            System.out.println("名称:" + m.getName());
            System.out.println("价格：" + m.getPrice());
            System.out.println("--------------------------");
        }
    }

    //2.实现用id查找电影
    public void searchById(int id){
        Movie m = new Movie();
        for (int i = 0; i < this.movies.length; i++) {
            m = movies[i];
            if(m.getId() == id){
                System.out.println("该电影详细如下");
                System.out.println("编号:" + m.getId());
                System.out.println("名称:" + m.getName());
                System.out.println("价格:" + m.getPrice());
                System.out.println("评分:" + m.getScore());
                System.out.println("导演:" + m.getDirector());
                System.out.println("主演:" + m.getActor());
                System.out.println("其他信息:" + m.getInfo());
                return;
            }
        }
        System.out.println("抱歉，没要找到相关电影");
    }


}
